<?php
/**
 * This file is part of PHPlaza (http://code.google.com/p/phplaza)
 * This file is licensed under the GNU Lesser General Public License
 *      http://www.gnu.org/licenses/lgpl.html
 *
 * No warranty is given, express or implied. Use at your own risk.
 */

namespace core::services::urlservice;

use core::collections as collections;

class SimpleURLService extends AbstractURLService
{
	private $page;
	
	const PAGE = 'page';
	
	public function getPage()
	{
		$get = new collections::GetData();
		if (isset($get[self::PAGE]))
		{
			$page = str_replace('.', '::', $get[self::PAGE]);
		} else {
			$page = 'application::DefaultPage';
		}
		
		$this->page = $this->_instantiate($page);
		return $this->page;
	}
	
	public function getPageUrl(core::Page $page = null)
	{
		if ($page == null)
		{
			$cpage = $this->page;
		} else {
			$cpage = $page;
		}
		
		return 'index.php6?page=' . $cpage->getId();
	}
}